home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGBLER / MATHASM.LZH / MUL32.ASM < prev    next >
Assembly Source File  |  1985-12-02  |  2KB  |  42 lines

  1. MUL32    PROC     NEAR
  2. ;***************************************************************
  3. ;                       32 bit multiplication routine
  4. ;                       multiplies DX:AX x CX:BX
  5. ;                       returns 64 bit product in DX:AX:CX:BX
  6. ;***************************************************************
  7.          PUSH     SI  
  8.          PUSH     DI
  9.          MOV      SI,DX       ;save OP1HI in SI
  10.          MOV      DI,AX       ;save OP1LO in DI
  11.          MUL      BX          ;OP1L0 x OP2LO
  12.          PUSH     AX          ;save 1st (32 bit) pp. on stack
  13.          PUSH     DX
  14. ;
  15.          MOV      AX,SI       ;OP1HI in AX
  16.          MUL      BX          ;OP1HI x OP2L0
  17.          POP      BX          ;add 2nd (48 bit) pp. to pp1
  18.          ADD      AX,BX
  19.          ADC      DX,0
  20.          PUSH     AX
  21.          MOV      BX,DX       ;pp1 + pp2 in BX:TOS:TOS+2
  22. ;
  23.          MOV      AX,DI       ;OP1LO in AX
  24.          MUL      CX          ;OP1LO x OP2HI
  25.          POP      DI          ;add 3rd (48 bit) pp. to pp1 + pp2
  26.          ADD      DI,AX
  27.          PUSH     DI
  28.          MOV      DI,0
  29.          ADC      BX,DX
  30.          ADC      DI,0        ;pp1+pp2+pp3 in DI:BX:TOS:TOS+2
  31. ;
  32.          MOV      AX,SI       ;OP1HI in AX
  33.          MUL      CX          ;OP1HI x OP2HI
  34.          ADD      AX,BX       ;add 4th (64 bit) pp. to pp1+pp2+pp3
  35.          ADC      DX,DI
  36.          POP      CX
  37.          POP      BX          ;final product in DX:AX:CX:BX
  38. ;
  39.          POP      DI
  40.          POP      SI
  41.          RET
  42. MUL32    ENDP